package com.source.lightfowl.basedata.dao;


import com.source.lightfowl.basedata.entity.MachineAlert;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;

/**
 * 数据访问接口
 * @author Administrator
 *
 */
public interface MachineAlertDao extends JpaRepository<MachineAlert,String>, JpaSpecificationExecutor<MachineAlert> {

    @Modifying
    @Transactional
    @Query(value = "update barcode_machine_alert SET idRead=1 where id=?1", nativeQuery = true)
    void updateRead(String id);

    @Modifying
    @Transactional
    @Query(value = "update barcode_machine_alert SET idRead=1 where id in(?1)", nativeQuery = true)
    void updateBatchRead(ArrayList<Integer> ids);

    @Modifying
    @Transactional
    @Query(value = "delete from barcode_machine_alert where id in(?1)", nativeQuery = true)
    void deleteBatch(ArrayList<Integer> ids);
}
